package org.zhang.mapper;

import org.apache.ibatis.annotations.*;
import org.zhang.entity.User;

import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("insert into user (name, password, age, gender, phone)" +
            " VALUES (#{name},#{password},#{age},#{gender},#{phone})")
    void insert(User user);


    @Update("update user set name=#{name} ,age=#{age} ,gender=#{gender} ,phone=#{phone} where id=#{id}")
    void updataUser(User user);


    @Delete("delete from user where id = #{id} ")
    void deleteUser(Integer id);

    @Select("select * from user  ")
    List<User> selectAll();

    @Select("select * from user where id = #{id} ORDER BY id desc")
    User selectById(Integer id);

    @Select("select * from user where name = #{name} and gender = #{gender} ORDER BY id desc")
    List<User> selectMores(@Param("name") String name, @Param("gender") String gender);

    @Select("select * from user where name like concat('%',#{name}, '%') and gender like concat('%' ,#{gender} ,'%') ORDER BY id desc")
    List<User> selectByLike(@Param("name") String name, @Param("gender") String gender);


    @Select("select * from user where name = #{name}")
    User selectByName(String name);


//    @Select("select * from user where name like concat('%',#{name}, '%') and gender like concat('%' ,#{gender} ,'%') ORDER BY id desc limit #{skipNum},#{pageSize}")
//    List<User> selectByPage(@Param("skipNum")Integer skipNum, @Param("pageSize") Integer pageSize,@Param("name") String name,@Param("gender") String gender);
//
//
//
//    @Select("select * from user where name like concat('%',#{name}, '%') and gender like concat('%' ,#{gender} ,'%') ORDER BY id desc")
//    List<User> selectCountByPage(@Param("name") String name, @Param("gender") String gender);

}